package com.tjsinfo.tjsoa.system.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tjsinfo.tjsoa.system.vo.Maxim;

/**
 * A data access object (DAO) providing persistence and search support for
 * Approve entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.tjsinfo.tjsoa.approve.Approve.Approve
 * @author MyEclipse Persistence Tools
 */

public class MaximDAO extends HibernateDaoSupport implements IMaximDAO {
	private static final Log log = LogFactory.getLog(MaximDAO.class);
	protected void initDao() {
		// do nothing
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.system.TjsUser.ITjsUserDAO#save(com.tjsinfo.tjsoa.system.TjsUser.TjsUser)
	 */
	public int save(Maxim transientInstance) {
		log.debug("saving Approve instance");
		int id=0;
		try {
			getHibernateTemplate().save(transientInstance);
			id=transientInstance.getId();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
		return id;
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.system.TjsUser.ITjsUserDAO#delete(com.tjsinfo.tjsoa.system.TjsUser.TjsUser)
	 */
	public void delete(Maxim persistentInstance) {
		log.debug("deleting Maxim instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public void update(Maxim persistentInstance) {
		log.debug("updating Maxim instance");
		try {
			getHibernateTemplate().update(persistentInstance);
			log.debug("update successful");
		} catch (RuntimeException re) {
			log.error("update failed", re);
			throw re;
		}
	}
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.system.Maxim.IMaximDAO#findById(java.lang.Integer)
	 */
	public Maxim findById(java.lang.Integer id) {
		log.debug("getting Maxim instance with id: " + id);
		try {
			Maxim instance = (Maxim) getHibernateTemplate().get(
					"com.tjsinfo.tjsoa.system.Maxim.Maxim", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}